qacli view
This subcommand allows you to output the diagnostics from a previous analysis.
Usage
view [-P <directory>] [-K <config name>] [-C <solution-name>] [--cma-project <project-name>] [-R] [-t <ANNSRC|DIAGLST|SUMMARY|SARIF>] -m <HTML|STDERR|STDOUT|XML|JSON> [--output-name <filename prefix>] [-o <directory>] [-c] [-a] [-1] [-b] [-Z] [-e] [-F <filelist>] [-X <max-count-filter>] [-S <0|1|2|3|4|5|6|7|8|9>] [-v<0|1|2|3|4|5|6|7|8|9>] [-N <msg-filter>] [-O <msg-filter>] [-D <NONE|SINGLE|DUPLICATE>] [-M] [-T <ALL|BASELINE|COMMENT|DASHBOARD|INTERACTIVE|MACRO|PRAGMA|VALIDATE>] ... [-s] [-n] [-r] [-f <format-string>] [-u <rule-format-string>] [-H <header-format-string>] [-x <xml-format-string>] [-d <xml-format-string>] [--xml-indent <indent>] [-i <indent>] [--] [-h] <source-file>
Extended Description
The view subcommand allows you to output the analysis results with a variety of different types (Diagnostic List, Annotated Source, SARIF, Summary), in a variety of mediums (Text, XML, JSON, HTML). Filtering allows the user to finely control what details, from which files make it into the output.
There are several different types of output available and can be chosen using the ‑‑type
(‑t
). It can have the following values:
- DIAGLST - Outputs a list of diagnostics for each file (containing diagnostics). If no output type is specified, then DIAGLST is the default. See Diagnostic List (DIAGLST) for more information.
- ANNSRC - Embeds the diagnostics output into a copy of the source file. See Annotated Source (ANNSRC) for more information.
- SARIF - Outputs all diagnostics for the project into a single file in SARIF format. See Static Analysis Results Interchange Format (SARIF) for more information.
- SUMMARY - Outputs a severity summary of all diagnostics for the project into a single file. See Severity Summary (SUMMARY) for more information.
DIAGLST
, ANNSRC
, and SARIF
options require an appropriate license.The output can be in one of several different formats (or mediums):
- HTML - For each source file, output results to an HTML file.
- JSON - Output results in JSON format (only supported for SARIF output type).
- STDERR - Output results as text, to standard error.
- STDOUT - Output results as text, to standard output.
- XML - For each source file, output results to an XML file.
For those who possess a completely unrestricted license, it is possible to view results on the command line or output them to a file.
qacli view ‑P <directory> ‑m STDOUT ‑rs
Options
Name, shorthand | Default | Description |
---|---|---|
‑‑collate‑output, ‑c |
When outputting results, rather than mirror the source code tree collate all output into a single directory. Duplicate files will not be overwritten, and their name will have a unique number appended. | |
‑‑config, ‑K |
For projects with multiple configurations, specify which configuration to use. If none specified, then the default will be used. | |
‑‑cma‑solution, ‑‑C |
Specify the name of the cross-module analysis (CMA) solution to view. Using this option implies that viewing will be conducted on all Helix QAC projects involved in the solution. Use ‑‑qaf‑project to specify the project to use for viewing the results of the analysis (the first Helix QAC project of the CMA solution is used by default). |
|
‑‑embed‑header‑messages, ‑e
|
Embed diagnostics from header files into source code (annotated source output only). Multi project CMA solutions (‑C ) are not supported currently. |
|
‑‑files, ‑F
|
Specify a path to a file containing a list of files for which to view results. If not supplied, results for all files in the project will be presented. | |
‑‑format, ‑f
|
Specify the format in which diagnostics should be presented. Refer to Formatting the Diagnostic String for more information. The default format string is: For annotated source (STDERR and STDOUT) is:
For annotated source (HTML) is: For SARIF output, the format string is empty. |
|
‑‑header‑format, ‑H
|
Specify the format in which diagnostics should be presented for header files. The content is identical to
If no value is provided and a value for
For annotated source (STDERR and STDOUT):
For annotated source (HTML): For annotated source (XML): |
|
‑‑help, ‑h
|
Displays usage information and exits. | |
‑‑ignore‑rest, ‑‑
|
Ignores the rest of the labelled arguments following this flag. | |
‑‑include‑zero‑headers, ‑Z
|
By default, all source files are output, but only headers with a non-zero number of diagnostics are shown. This option will show all source and header files, regardless of the diagnostics count. | |
‑‑indent, ‑i
|
-1 or 0 | Sets the number of spaces or tabs that will be output for each level of indentation (XML and JSON only). Positive numbers indicate spaces, negative numbers tabs. The default for XML is -1 and for JSON it is 0. |
‑‑max‑count, ‑X
|
Introduces a limit on the number of times that any message is displayed. The default of 0 indicates no limit is applied. | |
‑‑max‑severity, ‑v
|
Filter messages whose severity is more than the supplied severity. This can be used with the ‑‑min‑severity option to only output messages within a severity range or specific severity. 9 is acceptable, but will filter nothing. |
|
‑‑min‑severity, ‑S
|
Filter messages whose severity is less than the supplied severity. This can be used with the ‑‑max‑severity option to only output messages within a severity range or specific severity. 0 is acceptable, but will filter nothing. |
|
‑‑medium, ‑m
|
Specify the medium through which to show results. Viewing results are restricted under normal license provisions. JSON output is only available for the SARIF format. | |
‑‑multi‑homed‑format, ‑D
|
Format to use when displaying multi-homed (homeless) diagnostics, such as diagnostics from CMA. Possible values are:
|
|
‑‑nomsg, ‑N
|
Suppresses the display of the specified messages. Message numbers can be specified individually, or as a list, range or a combination of both: ‑‑nomsg 2356 ‑‑nomsg 1234,1236,1240 ‑‑nomsg 2111,2200‑2300 |
|
‑‑no‑line‑numbers, ‑b
|
Do not output line numbers (annotated source output only, excluding XML). | |
‑‑no‑header‑messages, ‑n
|
Do not show diagnostics from header files. | |
‑‑one‑line‑only, ‑1
|
Only output the source code if it has a diagnostic associated with it (annotated source output only). | |
‑‑only, ‑O
|
Only the specified warning messages will be shown. Message numbers can be specified individually, or as a list, range or a combination of both: ‑‑only 2356 ‑‑only 1234,1236,1240 ‑‑only 2111,2200‑2300 |
|
‑‑output‑name
|
For commands that produce a single file, such as ‑t SUMMARY ‑m XML or ‑t SARIF ‑m JSON prefix the filename with this value. This enables customization of the filename. |
|
‑‑output‑path, ‑o
|
Specify a path to an existing directory, with write access, to place the output files in. This option is only valid when the medium option is set to HTML, XML or JSON. Duplicate files will not be overwritten, and their name will have a unique number appended. | |
‑‑qaf‑project, ‑P
|
Specify a path to a valid Helix QAC project for which to view results. | |
‑‑relative‑paths, ‑R
|
Source files will be shown relative to the Source Root folder. | |
‑‑rule‑format, ‑u
|
Specify the format in which each rule violation should be presented. For each rule violation, the output defined by this string is appended to the diagnostic string output (i.e. based on the Refer to Formatting the Rule Violation String for more information |
|
‑‑rules, ‑r
|
For each message that is displayed, show the rule text for the rules that it is mapped to. This option requires either %r or %v to be present in the ‑‑format string parameter. If ‑‑format is not specified the default will be used. Refer to ‑‑format, ‑f for default values. |
|
‑‑suppression‑filter, ‑r
|
Specify which suppressed diagnostics to allow through the filter. Possible options are: ALL , BASELINE , COMMENT , DASHBOARD , INTERACTIVE , MACRO , PRAGMA , and VALIDATE .
The format specifier 'Suppression Justification' (%j ) will only be populated if you have selected this option.
DASHBOARD and VALIDATE are synonyms for INTERACTIVE .
|
|
‑‑type, ‑t
|
DIAGLST |
Specify the format that the results are presented in:
The
DIAGLST , ANNSRC , and SARIF options require an appropriate license. |
‑‑xml‑format, ‑x
|
Whenever XML output is requested a default set of elements will always be output these are described in the manual. You can also request that certain fields are output with each diagnostic by including them in the xml‑format string. The available specifiers are a subset of the fields available in the ‑‑format string.
Refer to Specifier to XML Mapping.
|
|
‑‑xml‑header‑format, ‑d
|
Specify which XML elements should be output for header files. The content is identical to To output all fields then use a wildcard, such as |
Examples
To output the results for a Helix QAC project to standard output, issue the following command:
To output to standard error, replace STDOUT
with STDERR
in the above command.
When the argument to the ‑‑medium
option is set to HTML, XML or JSON, a directory can be specified. Files will be output to this directory:
The directory must exist. The output will mirror the directory structure of the source files. To flatten the output into a single folder then add ‑‑collate‑output
(‑c
). Duplicate files will not be overwritten, and their name will have a unique number appended. For example:
To show rule information with each primary diagnostic (but not sub-diagnostics):
The ‑‑rules
(‑r
) option requires either %r
or %v
to be present in the ‑‑format
string parameter. Refer to Default Format Strings for more information.
Multi-homed messages—messages that are not generated for a specific project file but multiple locations—can be displayed in several formats using the ‑‑multi‑homed‑format, ‑D option.
Diagnostic List (DIAGLST)
This is the default output type and produces a list of diagnostics together with any sub-diagnostics. The exact format of the output is controlled by the ‑‑format
option. For information on how to alter this, refer to Formatting the Diagnostic String. To produce default output for a project in the current directory, use a command such as:
This will result in output like this example:
// ======= Results for /home/katie_mac/.config/Perforce/Helix-QAC-
2021.2/samples/sample_inspect_c-2021.2/src/inspect.c
/home/katie_mac/.config/Perforce/Helix-QAC-2021.2/samples/sample_inspect_c2021.2/src/inspect.c(0,1): Msg(2:0790) This translation unit makes use of floating types.
/home/katie_mac/.config/Perforce/Helix-QAC-2021.2/samples/sample_inspect_c-
2021.2/src/inspect.c(1,9): Msg(2:4600) The macro 'NULL' is also defined in '<stddef.h>'.
...
Annotated Source (ANNSRC)
To display diagnostics as annotations in the original source code (both source and headers) you should output in annotated source style:
You can add the ‑‑one‑line‑only
argument (‑1
) to output only those lines from the source code that have diagnostics associated with them:
Rather than having individual entries for each source file and header separately, it’s possible to embed the headers into the annotated source listing using ‑‑embed‑header‑messages
argument (‑e
). This form of output is not supported for multi-project CMA solutions.
The diagnostic output for included files will only show the top-level diagnostic - no sub-diagnostics will be output.
It is also possible to specify how any included diagnostics are formatted using their own formatting string: ‑‑header‑format‑string
argument (‑H
). The content is identical to the ‑‑format
option - refer to Formatting the Diagnostic String.
If no value is provided and a value for ‑‑format
is supplied, then this same value will be used as the header format. If both a ‑‑header‑format‑string
and ‑‑format
are not supplied, then the following default values will be used:
For output to STDOUT
and STDERR
:
For output to HTML:
For output to XML:
These values are similar to the defaults for ‑‑format
, but with leading %?C%(%^%)
removed.
Static Analysis Results Interchange Format (SARIF)
The Static Analysis Results Interchange Format (SARIF) is an industry standard format for the output of static analysis tools.
We output to version (2.1.0) of the standard, full details of the standard can be found here (external PDF).
To output in SARIF format use ‑‑type SARIF
and ‑‑medium JSON
. For example:
This will output a JSON based SARIF file to the current directory, with the default name project.sarif
. If the file already exists, then the command will fail. You can either:
- Remove the file and retry the command.
- Output to a different directory, using the
‑‑output‑path
option. - Output to a different filename, using the
‑‑output‑name
option. - Use the
‑‑collate‑output
option so that a unique filename is generated based upon the name, for exampleproject.sarif
is first tried, thenproject(1).sarif
etc.
To output to another directory, use the ‑‑output‑path
. For example:
To output to a specific named file, use the ‑‑output‑name
. For example:
The appropriate extension (.sarif
) will automatically be added. Both ‑‑output‑path
and ‑‑output‑name
can be used together to exactly dictate the location and name for the output file.
SARIF files are JSON based and can be very large. They are automatically output in the most efficient representation possible i.e., minimal spacing and newlines, which are not easily readable by a casual observer. For this reason, it may be preferable to pass them through a JSON beautifier. Several are available, including a default one shipped with Python. For example:
‑‑format
option. For SARIF output this has an empty default i.e. no custom formatting string will be produced. You can explicitly supply a format string, but because there is no obvious mapping to a SARIF field it will be output in the SARIF “Property Bag” called “formattedString”. It is unlikely any SARIF reader will display this without some customization.Severity Summary (SUMMARY)
To output a concise severity summary of a project use ‑‑type SUMMARY
. For example:
This will output the summary to the console, where it can be redirected to a file if needed.
Naturally, you can also output to a HTML or XML file. By default, the file will be called severity_summary.xml
(or .html
) and be in the current working directory.
To output to another directory, use ‑‑output‑path
. For example:
To output to a specific named file, use ‑‑output‑name
. For example:
The appropriate extension (.xml
or .html
) will automatically be added. Both ‑‑output‑path
and ‑‑output‑name
can be used together to exactly dictate the location and name for the output file.
For XML output an additional schema that describes the file format will be output. It will be called cli_view_severity_summary.xsd
For multi-project CMA solutions one file per underlying project will be created. The name will be severity_summary.xml
(or .html
), then severity_summary(1).xml
and so on.
- Filtering Messages
- Formatting the Diagnostic String
- Formatting the Rule Violation String
- Conditional Formatting
- Message Text Control
- Format Specifier Restrictions
- An Example Message Format
- Default Format Strings
- Formatting in Windows command files (.bat)
- Viewing CMA Projects
- XML Output
- Deprecated Commands